const path = require('path')
const resolve = (dir) => {
  return path.join(__dirname, dir)
}
const BASE_URL = process.env.NODE_ENV === 'production' ? '/production-sub-path/' : '/dev'
console.log('------BASE_URL-------')
console.log(BASE_URL)
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
module.exports = {
  publicPath: './',
  //打包时不生成Map文件,减少压缩体积，加快打包速度
  productionSourceMap: false,
  css: {
    //为 ant design vue 针对性配置 less
    loaderOptions: {
      less: {
        lessOptions: {
          javascriptEnabled: true,
        },
      },
    },
  },
  configureWebpack: {
    plugins: [new BundleAnalyzerPlugin()],
  },
  //配置别名
  chainWebpack: (config) => {
    config.resolve.alias.set('@', resolve('src')).set('_c', resolve('src/components'))
  },
  devServer: {
    overlay: {
      // 让浏览器 overlay 同时显示警告和错误
      warnings: true,
      errors: true,
    },
    disableHostCheck: true,
    // host: 'localhost',
    https: false,
    open: true,
    hot: true,
    hotOnly: true, // 热更新
    // 配置跨域处理,只有一个代理
    // proxy: 'http://localhost:8080'
    disableHostCheck: true,
    compress: false,
    /*     proxy: {
      //配置多个代理
      '/qcj/api/': {
        //target: 'http://192.168.9.18:18888',
        //target: 'http://www.ymflow.cn',
        target: 'http://ymflow.frp.teqiyi.com:8080',
        changeOrigin: true,
        crossOrigin: true,
      },
      '/api/': {
        //target: 'http://192.168.9.18:18888',
        //target: 'http://www.ymflow.cn',
        target: 'http://ymflow.frp.teqiyi.com:8080',
        changeOrigin: true,
        crossOrigin: true,
      },
    },  */
  },
}
